<template>
  <div class="haoshu">
    <h2>好书专区</h2>
    <router-link v-for="item in this.hotmsg" :key="item.id" :to="{path :'/readview',query:{id: item.id}}">
      <div class="mainbox">
        <div class="imgbox">
          <img :src="item.iconUrl" alt="" />
        </div>
        <div class="tuijianeirong">
          <h3>{{ item.title }}</h3>
          <div class="fengge">{{ item.author }}/{{ item.category }}</div>
          <div class="jianjie">
            {{ item.content }}
          </div>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
import { get } from "../http/request";
export default {
  name: "haoshu",
  data() {
    return {
      hotmsg: "",
    };
  },
  methods: {
    async getmydata() {
      await get(
        `https://apis.netstart.cn/yunyuedu/category/original/data.json?id=8&gender=female&sort=2&pay=0&state=0&page=1`
      ).then((content) => {
        console.log(content);
        // 获取人气爆款的数据
        let hotmsg = content.data.books;
        this.hotmsg = hotmsg;
        console.log(hotmsg);
      });
    },
  },
  created() {
    this.getmydata();
  },
};
</script>

<style lang="scss" scoped>
.haoshu {
    margin-top: 20px;
  font-size: 16px;
  width: 100%;
  padding: 0 10px;
  box-sizing: border-box;
  h2 {
    margin-bottom: 10px;
  }
  a {
    display: block;
    width: 100%;
    height: 180px;
    text-decoration: none;
    color: black;
    .mainbox {
      width: 100%;
      height: 180px;
      display: flex;
      .imgbox {
        width: 100px;
        height: 150px;
        margin: 10px;
        img {
          width: 100px;
          height: 150px;
        }
      }
      .tuijianeirong {
        width: 220px;
        height: 180px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;

        .jianjie {
          width: 220px;
          height: auto;
          display: -webkit-box;
          overflow: hidden; /*超出隐藏*/
          text-overflow: ellipsis; /*隐藏后添加省略号*/
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3; //想显示多少行
        }
      }
    }
  }
}
</style>